#include "include/priority.h"
#include "include/simul.h"
#include "include/task.h"
#include "include/resource.h"
#include <qdebug.h>
#define boost_priority 100

int  get_global_resource_ceiling_priority(uint32_t resource_type)
{
   int max_prior=PrioMin;
    for(int i=0;i<get_tasknum();i++)
    {
        for(int j=0;j<RESOURCE_MAX;j++)
        if(max_prior>taskSets[i].task_priority&&taskSets[i].resource_type[j]==resource_type&&taskSets[i].resource_duration[j]!=0)
            max_prior=taskSets[i].task_priority;
    }
   // qDebug()<<"全局资源"<<resource_type<<"优先级更新为"<<max_prior-boost_priority;
    return max_prior-boost_priority;
}

int  get_local_resource_ceiling_priority(uint32_t resource_type)
{
   int max_prior=PrioMin;
    for(int i=0;i<get_tasknum();i++)
    {
        for(int j=0;j<RESOURCE_MAX;j++)
        if(max_prior>taskSets[i].task_priority&&taskSets[i].resource_type[j]==resource_type&&taskSets[i].resource_duration[j]!=0)
            max_prior=taskSets[i].task_priority;
    }
   // qDebug()<<"局部资源"<<resource_type<<"优先级更新为"<<max_prior;
    return max_prior;
}



